package cn.growthgate.fgo.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.ext.web.WebRenderExt;

import cn.growthgate.fgo.service.IMenuService;
import cn.growthgate.fgo.util.AuthenticationUtils;
import cn.growthgate.fgo.util.SpringUtils;

public class WebTemplateExt implements WebRenderExt {

	@Override
	public void modify(Template template, GroupTemplate gt, HttpServletRequest request, HttpServletResponse response) {
		IMenuService menuService = SpringUtils.getBean(IMenuService.class);
		
		template.binding("nowTime", System.currentTimeMillis());
		template.binding("loginUser", AuthenticationUtils.getLoginSimpleUser());
		template.binding("userMenus", menuService.getUserMenus());
	}

}
